<?php

class Add_Publish_Article_SavePost_Validate_Tags extends Ext_Validate_Abstract
{
    protected $_recommendTags;
    protected $_definedTags;

    const TAGS_EMPTY   = 'tagsEmpty';
    protected $_messageTemplates = array(
        self::TAGS_EMPTY   => "Recommend tags and defined tags all empty.",
    );
    
    public function __construct($articleId, $recommendTags, $definedTags)
    {
        $this->_articleId       = $articleId;
        $this->_recommendTags   = $recommendTags;
        $this->_definedTags     = $definedTags;
        
        $this->_messager = new Ext_Messager($this->_messageTemplates);
    }
    
    public function isValid()
    {
        if(!$this->_recommendTags && !$this->_definedTags){
            $this->addMessage($this->_messager->addMessage(self::TAGS_EMPTY));
            return false;
        }
        
        return true;
    }

}
